<template>
  <view>
    <uni-nav-bar :color="props.option.color || '#000000'"
      :backgroundColor="props.option.backgroundColor || 'transparent'" :right-icon="props.option.rightIcon"
      :statusBar="props.option.statusBar"
      :border="false" :title="props.option.title"
      @clickLeft="clickLeft">
      <template #left>
        <uni-icons :type="props.option.leftIcon || 'left'" size="22"></uni-icons>
      </template>
    </uni-nav-bar>
    <self-popup ref="popupTips" :option="{title: props.option.tips, content: props.option.content}"></self-popup>
  </view>
</template>

<script setup>
import SelfPopup from '@/components/SelfToast/popup'
import { ref } from 'vue'
// #ifdef H5
import jsBridge from '@/utils/jsBridge'
// #endif
const popupTips = ref('')
const props = defineProps({
  option: {
    type: Object,
    default: () => {}
  }
})

const clickLeft = () => {
  if (props.option.nativeBack) {
    // #ifdef H5
    jsBridge.webCallHandler('navigateBack')
    // #endif
    // #ifdef MP-WEIXIN
    uni.navigateBack({
      fail: () => {
        uni.switchTab({
          url: '/pages/index'
        })
      }
    })
    // #endif
  } else {
    uni.navigateBack()
  }
}
</script>

<style scoped lang="scss">

</style>
